package com.ljpz.manage.service;

import com.github.abel533.entity.Example;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljpz.common.bean.EasyUIResult;
import com.ljpz.manage.mapper.ContentMapper;
import com.ljpz.manage.pojo.Content;
import com.ljpz.manage.pojo.Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liujunchen on 2016/12/9.
 */
@Service
public class ContentService extends   BaseService<Content> {
     @Autowired
    ContentMapper   contentMapper  ;
    public EasyUIResult queryListByCategoryId(Long categoryId, Integer page, Integer rows) {
        // 设置分页参数
        PageHelper.startPage(page,rows);
        Example example = new Example(Content.class);
        example.setOrderByClause("created desc");
        example.createCriteria().andEqualTo("categoryId",categoryId) ;
        List<Content>contents  = contentMapper.selectByExample(example)  ;
        //获取分页后的的的信息
        PageInfo<Content> pageinfo =  new PageInfo<Content>(contents)  ;
        return   new EasyUIResult(pageinfo.getTotal(), pageinfo.getList())   ;
    }
}
